/*************************************************************************
	> File Name: oj-275.cpp
	> Author: Wang Bo
	> Mail: 1276106221@qq.com
	> Created Time: 2021年01月28日 星期四 10时57分42秒
 ************************************************************************/
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int n;
char chr[105];
int ans[250] = {1, 1};

int mul(char *a) {
    if (a[0] == '0') {
        for (int i = 1; i <= ans[0]; ++i) {
            ans[i] = 0;
        }
        ans[0] = 1;
        return -1;
    }
    if (strlen(a) == 4) {
        for (int i = ans[0]; i > 0; --i) {
            ans[i + 2] = ans[i];
        }
        ans[1] = ans[2] = 0;
        ans[0] += 2;
        return 0;
    }
    int temp[10] = {strlen(a) - 1};
    for (int i = 1, j = temp[0] - 1; i <= temp[0]; ++i, --j) {
        temp[i] = a[j] - '0';
    }
    int res[250] = {max(ans[0], temp[0])};
    for (int i = 1; i <= ans[0]; ++i) {
        for (int j = 1; j <= temp[0]; ++j) {
            res[i + j - 1] += ans[i] * temp[j];
        }
    }
    for (int i = 1; i <= res[0]; ++i) {
        res[i + 1] += res[i] / 10;
        res[i] %= 10;
    }
    for (int i = res[0] + 1; res[i]; ++i) {
        res[0] = i;
        res[i + 1] += res[i] / 10;
        res[i] %= 10;
    }
    for (int i = res[0]; i > 0; --i) {
        ans[i] = res[i];
    }
    ans[0] = res[0];
    return 0;
}

int main() {
    cin >> n >> chr;
    for (int i = 0; i < n; ++i) {
        char a[5], b[5], c[5], d[5];
        cin >> a >> b >> c >> d;
        int fl = 0;
        switch(chr[i]) {
            case 'A' : fl = mul(a); break;
            case 'B' : fl = mul(b); break;
            case 'C' : fl = mul(c); break;
            case 'D' : fl = mul(d); break;
        }
        if (fl == -1) {
            cout << 0 << endl;
            return 0;
        }
    }
    char real_ans[250] = {0};
    if (ans[n * 2 + 1]) {
        cout << 1 << endl;
        return 0;
    }
    for (int i = n * 2, j = 0; i > 0; --i, ++j) {
        real_ans[j] = ans[i] + '0';
    }
    for (int i = strlen(real_ans) - 1; i > 0; --i) {
        if (real_ans[i] != '0') break;
        real_ans[i] = 0;
    }
    cout << "0." << real_ans << endl; 
    return 0;
}
